package com.woniuxy.springboot.mybatis.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.ApiSelectorBuilder;
import springfox.documentation.spring.web.plugins.Docket;

@Configuration
public class SwaggerJavaConfig {
    @Bean
    public Docket createRequestApi() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2);
        ApiInfo apiInfo = apiInfo();
        docket.apiInfo(apiInfo);//设置接口信息
        ApiSelectorBuilder apiSelectorBuilder = docket.apiInfo(apiInfo).select();
        Docket newDocket = apiSelectorBuilder.apis(RequestHandlerSelectors.basePackage("com.woniuxy.springboot.mybatis.controller")).build();
        return newDocket;
    }

    public ApiInfo apiInfo() {
        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("控制器api接口")//标题
                .description("HR人力资源管理系统的API接口")//描述
                .contact(new Contact("Giles", "http://www.lvfeilong.org", "57646349@qq.com"))//联系人
                .version("v1.0")//版本
                .license("蜗牛学院") //版权
                .build();
        return apiInfo;
    }
}
